const {
  appointmentList_mock
} = require("../../../mock/appointment.js")
const {
  baseUrl,
  getRequest,
  postRequest
} = require("../../../utils/request.js")
Page({

  /**
   * 页面的初始数据
   */
  data: {
    //预约列表
    appointmentList: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.http_appointment_findAllByUserId()
    this.setData({ //模拟数据
      //appointmentList: appointmentList_mock
    })
  },
  /**
   * 预约详情页面
   */
  onAppointmentDescPage(e) {
    wx.navigateTo({
      url: '/pages/user/appointment/desc/desc?id='+e.currentTarget.dataset.appointmentid,
    })
  },
  /**
   * 根据用户查询所有预约
   */
  http_appointment_findAllByUserId() {
    wx.getStorage({
      key: "userId",
      success: res => {
        //console.log(res.data)
        getRequest(baseUrl + "/front/appointment/findAllByUserId", {
          userId: res.data
        }).then(res => {
          if (res.code == 200) {
            this.setData({
              appointmentList: res.data
            })
          }
        })
      }
    })
  },
})